<?php

putenv("DISPLAY=:1");
putenv("XAUTHORITY=/var/www/.Xauthority");

ini_set('display_errors', 1);
error_reporting(E_ALL);

include_once 'Bot.php';
include_once 'Api.php';

$redmineId  = $argv[1];
$issueId    = $argv[2];
$name       = urldecode($argv[3]);
$title      = urldecode($argv[4]);

if (!$redmineId) {
    exit();
}

$dbus = new Dbus(Dbus::BUS_SESSION, true);
$n = $dbus->createProxy('com.Skype.API', '/com/Skype', 'com.Skype.API');
$n->Invoke('NAME SEND_ASSIGN');
$n->Invoke('PROTOCOL 8');
$dbus->registerObject('/com/Skype/Client', 'com.Skype.API.Client', 'Bot');

$user   = Bot::getInstance()->getUserByIdRedmine($redmineId);

$msg = 'Создан новый таск в проекте TG-approve.' . "\n"
     . 'Задача:  http://pm.vs58.net/issues/' . $issueId  . "\n"
     . 'Название: ' .  $title  . "\n"
     . 'Автор: ' . iconv("WINDOWS-1251","UTF-8", $name)  . "\n";

Bot::getInstance()->sendNotifyToSkype($user['skype'], $msg);
exit();